//2009/09/08 23:21:02
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class CombinationLock
{
public:
    double degreesTurned(vector <int> combo, int size, int start)
    {
        int N = combo.size(), L = N;
        double ret = 0;
        int at = start;
        int dir = 1;       //we're calling 1 counterclockwise and 1 clockwise
        for (int i = 0; i < L; i++, N--)
        {
            int K;
            if (dir == 1) K = combo[i] - at;
            else K = at - combo[i];
            if (K < 0) K += size;
            ret += 360.0 * (N + 1.0*K/size);
            at = combo[i];
            dir = -dir;
        }
        return ret;

    }
};
